import pymysql
import random


#
def randomString():
    s = ""
    for index in range(0, 5):
        i = random.randint(65, 65 + 25)
        c = chr(i)
        s += c
    return s


conn = pymysql.connect(host='47.94.152.192', port=3306, user='kikt', passwd='power123', db='app', charset='utf8')
cur = conn.cursor()

cur.execute("SELECT * FROM user WHERE email = '%s'" % "guest@kikt.tk")
for r in cur.fetchall():
    print(r)


def testInsert():
    name = randomString()
    pwd = "123456"
    email = "%s@163.com" % name
    cur.execute("INSERT INTO user (username, pwd, email) VALUES ('%s','%s','%s');" % (name, pwd, email))


testInsert()
testInsert()
conn.commit()

cur.close()
conn.close()
